import { ref } from "vue-demi";
import { free } from "@/api/head";
export const adverti = ref();
export const film = ref()
export const publicity = ref()
export const recode = ref()
export const creativity = ref()



/**
 *  @function open 打开窗口
 *  @function getadverti 获取<广告>的数据
 *  @function getfilm 获取<剧情短片>的数据
 *  @function getpublicity 获取<宣传片>的数据
 */

/**
 * 
 * @param {NewType} url 
 */

export function open(url) {
    window.open(url, '_blank')
}
export function getadverti() {
    free(
        "https://apis.netstart.cn/xpc/home/cateRecommend?channel=home_channel_plot&cateName=广告"
    ).then((res) => {
        const transition = {
            0: res.children.slice(1, 5),
            1: res.children.slice(5, 9),
            2: res.children.slice(10, 14),
            3: res.children.slice(15, 19),
            4: res.children.slice(20, 21),
        };
        adverti.value = transition;
    });
}


export function getfilm() {
    free(
        "https://apis.netstart.cn/xpc/home/cateRecommend?channel=home_channel_plot&cateName=剧情短片"
    ).then((res) => {
        const transition = {
            0: res.children.slice(1, 5),
            1: res.children.slice(5, 9),
            2: res.children.slice(10, 14),
            3: res.children.slice(15, 19),
            4: res.children.slice(20, 21),
        };
        film.value = transition;
    });
}


export function getpublicity() {
    free(
        "https://apis.netstart.cn/xpc/home/cateRecommend?channel=home_channel_plot&cateName=宣传片"
    ).then((res) => {
        const transition = {
            0: res.children.slice(1, 5),
            1: res.children.slice(5, 9),
            2: res.children.slice(10, 14),
            3: res.children.slice(15, 19),
            4: res.children.slice(20, 21),
        };
        publicity.value = transition;
    });
}

export function getrecode() {
    free(
        "https://apis.netstart.cn/xpc/home/cateRecommend?channel=home_channel_plot&cateName=纪录"
    ).then((res) => {
        const transition = {
            0: res.children.slice(1, 5),
            1: res.children.slice(5, 9),
            2: res.children.slice(10, 14),
            3: res.children.slice(15, 19),
            4: res.children.slice(20, 21),
        };
        recode.value = transition;
    });
}

export function getcreativity() {
    free(
        "https://apis.netstart.cn/xpc/home/cateRecommend?channel=home_channel_plot&cateName=创意"
    ).then((res) => {
        const transition = {
            0: res.children.slice(1, 5),
            1: res.children.slice(5, 9),
            2: res.children.slice(10, 14),
            3: res.children.slice(15, 19),
            4: res.children.slice(20, 21),
        };
        creativity.value = transition;
    });
}